<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>作业评讲</title>
    <style>
        table{
            width: 500px;
            border-collapse: collapse;
        }
        thead{
            background-color: gray;
        }
        tr>td{
            border:1px solid black;
        }
    </style>
</head>
<body>
    <table>
        <thead>
            <tr>
                <td>姓名</td>
                <td>性别</td>
                <td>年龄</td>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>张三</td>
                <td>男</td>
                <td>20</td>
            </tr>
            <tr>
                <td>李四</td>
                <td>女</td>
                <td>20</td>
            </tr>
            <tr>
                <td>王五</td>
                <td>男</td>
                <td>25</td>
            </tr>
            <tr>
                <td>小强</td>
                <td>男</td>
                <td>33</td>
            </tr>
            <tr>
                <td>小刚</td>
                <td>女</td>
                <td>22</td>
            </tr>
        </tbody>
    </table>
    <script>
        let trs = document.querySelectorAll("tbody>tr");
        for(let i = 0;i < trs.length;i++){
            trs[i].onmouseover = function(){
                this.style.backgroundColor = "blue";
            }
            trs[i].onmouseout = function(){
                this.style.backgroundColor = "";
            }
        }
    </script>
</body>
</html>